---
title: "SQL-005: Valid source/category check"
summary: Count matching TASK_CATEGORY_CODE rows to validate a task's source/category combination.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
---

# SQL-005 Valid sourcecategory check

Runs a scalar count query against `TASK_CATEGORY_CODE` to validate that a task's source system and category code combination is a registered pairing (rule `TASK1`).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-005 |
| **Operation type** | Read |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | `[unqualified]`** |
| **Command type** | Text |
| **Business object** | N/A (Application layer) |
| **Criteria property** | N/A |
| **Lifecycle method** | N/A |
| **Application class** | `clsTaskBusinessRules` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Source` | Input | String | 5 | Task source code being validated |
| `:Category` | Input | String | 5 | Task category code being validated |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [TASK_CATEGORY_CODE](../database-tables.md#task_category_code) | SELECT | `TASK_SOURCE_CODE`, `CODE` |

## Sample SQL

```sql
-- RequestType = Scalar; executed directly from the rule handler
SELECT
  COUNT(*)
FROM
  TASK_CATEGORY_CODE
WHERE
  TASK_SOURCE_CODE = :Source
  AND CODE = :Category
```

## Operations and processes
- [Create/insert a task](../operations/create-insert-task.md)
- [Update a task](../operations/update-task.md)

## Business rules
- [BR-005: The Task Source Code / Task Category Code combination must exist](../business-rules.md#br-005-the-task-source-code-task-category-code-combination-must-exist)
- [BR-026: Descendant task types may override common rule outcomes](../business-rules.md#br-026-descendant-task-types-may-override-common-rule-outcomes)

## Sources
- SAIF.Business.Tasks/clsTaskBusinessRules.vb
